package com.farm.kaiping.controller;

import com.farm.common.security.AnonymousAccess;
import com.farm.common.util.R;
import com.farm.kaiping.entity.FarmUser;
import com.farm.kaiping.po.SysUserLoginPO;
import com.farm.kaiping.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录控制层
 *
 * @author zhuhui
 * @since 2024-11-26 22:58:51
 */
@RestController
@RequestMapping("/login")
@AllArgsConstructor
@Api(tags = "用户登录控制器")
public class LoginController {

    private final SysUserService sysUserService;

    @ApiOperation(value = "用户登录", notes = "权限：用户登录")
    @AnonymousAccess
    @PostMapping
    public R<FarmUser> getSysDeptPage(@RequestBody SysUserLoginPO sysUserLoginPO) {
        try{
            return R.ok(sysUserService.getUserLogin(sysUserLoginPO));
        }catch (Exception e){
            return R.failed(e.getMessage());
        }
    }


}
